<div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="<?=site_url()?>">首页</a>
            	<span class="crumb-step">&gt;</span><span class="crumb-name">分类管理</span></div>
        </div>
        <div class="search-wrap">
            <div class="search-content">
                <form action="<?=site_url('sort/index')?>" method="get">
                    <table class="search-tab">
                        <tr>
                            <th width="70">关键字:</th>
                            <td><input class="common-text" placeholder="关键字" name="keywords" value="<?=empty($_GET['keywords'])? '' : $_GET['keywords'] ?>" id="" type="text"></td>
                            <td><input class="btn btn-primary btn2" value="查询" type="submit"></td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
        <div class="result-wrap">
                <div class="result-title">
                    <div class="result-list">
                        <a href="<?=site_url('sort/create')?>"><i class="icon-font"></i>新增分类</a>
                    </div>
                </div>
                <div class="result-content">
                    <table class="result-tab" width="100%">
                        <tr>
                            <th>ID</th>
                            <th>排序</th>
                            <th>分类名称</th>
                            <th>描述</th>
                            <th>操作</th>
                        </tr>
                        <?php foreach($list as $k => $v):?>
                        <tr>
                            <td><?=$v['id']?></td>
                            <td>
                                <input class="common-input sort-input" value="<?=$v['sort']?>" type="text" onclick="update_sort(<?=$v['id']?>,<?=$v['sort']?>)">
                            </td>
                            <td><?=$v['title']?></td>
                            <td><?=$v['described']?></td>
                            <td>
                                <a class="link-update" href="<?=site_url('sort/update?sid='.$v['id'])?>">修改</a>
                                <a class="link-del" href="javascript:;" onclick="delete_sort(<?=$v['id']?>)">删除</a>
                            </td>
                        </tr>
                        <?php endforeach;?>
                    </table>
                    <div class="list-page"> <?=$page?></div>
                </div>
        </div>
<script type="text/javascript">
    layer.config({
        extend: 'extend/layer.ext.js'
    });

    function update_sort(sid,val){
        layer.prompt({
            title: '输入数值（数值大的靠前）',
            value:val
        }, function(sort){
            $.post("<?=site_url('sort/set_sort')?>",{sid:sid,sort:sort},function(data){
                if(data == 1){
                    layer.alert("操作成功！",{
                        icon:1,
                    },function(){
                        location.reload();
                    });
                }else{
                    layer.alert(data,{
                        icon:2,
                    });
                }
            });
        });
    }

    function delete_sort(sid){
        layer.confirm('删除之后该分类下的所有项目和文章会重置为‘未分类’状态，是否确认？', {
            icon:0,
            btn: ['确定','取消'] //按钮
        }, function(){
            $.post("<?=site_url('sort/delete')?>",{sid:sid},function(data){
                if(data == 1){
                    layer.alert("操作成功！",{
                        icon:1,
                    },function(){
                        location.reload();
                    });
                }else{
                    layer.alert(data,{
                        icon:2,
                    });
                }
            });
        });
    }
</script>